package com.ruoyi.web.controller.article;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ArtTag;
import com.ruoyi.system.service.IArtTagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * artTagController
 * 
 * @author star
 * @date 2024-09-05
 */
@RestController
@RequestMapping("/system/art_tag")
public class ArtTagController extends BaseController
{
    @Autowired
    private IArtTagService artTagService;

    /**
     * 查询artTag列表
     */
    @PreAuthorize("@ss.hasPermi('system:art_tag:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArtTag artTag)
    {
        startPage();
        List<ArtTag> list = artTagService.selectArtTagList(artTag);
        return getDataTable(list);
    }

    /**
     * 导出artTag列表
     */
    @PreAuthorize("@ss.hasPermi('system:art_tag:export')")
    @Log(title = "artTag", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArtTag artTag)
    {
        List<ArtTag> list = artTagService.selectArtTagList(artTag);
        ExcelUtil<ArtTag> util = new ExcelUtil<ArtTag>(ArtTag.class);
        util.exportExcel(response, list, "artTag数据");
    }

    /**
     * 获取artTag详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:art_tag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(artTagService.selectArtTagById(id));
    }

    /**
     * 新增artTag
     */
    @PreAuthorize("@ss.hasPermi('system:art_tag:add')")
    @Log(title = "artTag", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArtTag artTag)
    {
        return toAjax(artTagService.insertArtTag(artTag));
    }

    /**
     * 修改artTag
     */
    @PreAuthorize("@ss.hasPermi('system:art_tag:edit')")
    @Log(title = "artTag", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArtTag artTag)
    {
        return toAjax(artTagService.updateArtTag(artTag));
    }

    /**
     * 删除artTag
     */
    @PreAuthorize("@ss.hasPermi('system:art_tag:remove')")
    @Log(title = "artTag", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(artTagService.deleteArtTagByIds(ids));
    }
}
